package com.fpost.manager;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;

import com.fpost.dao.impl.UserDAO;
import com.fpost.domain.User;

public class UserManager {
	
	public Long save(User user) throws HibernateException {
		UserDAO dao = new UserDAO();
		return dao.save(user);
	}

	public void saveOrUpdate(User user) throws HibernateException {
		UserDAO dao = new UserDAO();
		dao.saveOrUpdate(user);
		
	}

	public void delete(long id) throws HibernateException {
		UserDAO dao = new UserDAO();
		dao.delete(id);
		
	}

	public User get(long id) throws HibernateException {
		UserDAO dao = new UserDAO();
		return dao.get(id);
	}
	
	public User getByUsername(String username) throws HibernateException {
		UserDAO dao = new UserDAO();
		return dao.getByUsername(username);
	}
	
	public List<User> getAll() {		
		UserDAO dao = new UserDAO();
		return dao.getAll();
	}
 
}
